package jsp;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;


public class jsp {

	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		Class.forName("com.mysql.jdbc.Driver");
		String url="jdbc:mysql://localhost:3306/jsp";
		String username="root";
		String password="123";
		Connection conn=DriverManager.getConnection(url, username, password);
		
//		String insertSqlStatic="insert into tb_student (age,sex,name,id) values ('21','1','zs','12')";
//		Statement ps=conn.prepareStatement(insertSqlStatic);
				
		String insertSqlDynamic="insert into tb_student (age,sex,name,id) values (?,?,?,?)";
		PreparedStatement dps=conn.prepareStatement(insertSqlDynamic);
		dps.setInt(1,22);
		dps.setInt(2,0);
		dps.setString(3,"ls");
		dps.setInt(4,2);		
		
//		ps.executeUpdate(insertSqlStatic);
		dps.executeUpdate();
		
		System.out.print("ok");
	}

}
